<?php

/*   __________________________________________________
    |  Obfuscated by YAK Pro - Php Obfuscator          |
    |              on 2018-07-17 15:20:06              |
    |    GitHub: https://github.com/pk-fr/yakpro-po    |
    |__________________________________________________|
*/
namespace MmqmMarket\controller\mobile;

defined("IN_IA") || die("Access Denied");
class ShoppingCart extends \MmqmMarket\controller\BaseController
{
    public function __construct($Site, $arguments)
    {
        parent::__construct($Site, $arguments);
        method_exists($this, $GLOBALS["_GPC"]["ac"]) && ($this->{$GLOBALS["_GPC"]["ac"]}() && die || die);
        $GLOBALS["PARAMS"] = array("CartGroupByMarket" => self::CartGroupByMarket(), "ActiveMarketID" => \MmqmMarket\model\Member::getActiveMarketID());
        include $this->template();
    }
    private function switchActiveMarketInCart()
    {
        \MmqmMarket\model\Member::insertNewFans(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, intval($GLOBALS["_GPC"]["ActiveMarketID"]));
    }
    private function switchGoodsActiveStatusInCart()
    {
        \MmqmMarket\model\SQL::insertOrUpdate("cart", array("id" => intval($GLOBALS["_GPC"]["CartID"]), "checked" => intval($GLOBALS["_GPC"]["ActiveStatus"])));
    }
    private function CartGroupByMarket()
    {
        $Markets = \MmqmMarket\model\Market::getByIds(\MmqmMarket\model\Cart::getJoinedMarketIDFromAllExists());
        $Carts = \MmqmMarket\model\Cart::getAllExists();
        foreach ($Carts as $key => $value) {
            $Markets[$value["market_id"]]["Cart"][] = $value;
        }
        return $Markets;
    }
    private function JsonCartGroupByMarket()
    {
        die(json_encode(self::CartGroupByMarket()));
    }
    private function deleteItemsInCart()
    {
        \MmqmMarket\model\SQL::delete("cart", array("id" => $GLOBALS["_GPC"]["CartID"]));
        self::JsonCartGroupByMarket();
    }
}